/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2017
 */

package com.shop.pandian.app.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.shop.pandian.framework.base.dao.BaseUpdatableEntity;
import com.shop.pandian.util.ConvertUtils;

/**
 * @author Xi Wei
 * @version 1.0
 * @since 1.0
 */
 @Entity
@Table(name = "acct_user")
public class AcctUser extends BaseUpdatableEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;

	


	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
	@NotBlank @Length(max=255)
	
	@Column(name = "login_name", unique = true, nullable = false, insertable = true, updatable = true, length = 45)
	private java.lang.String loginName; //loginName
	@NotBlank @Length(max=250)
	
	@Column(name = "user_name", unique = false, nullable = false, insertable = true, updatable = true, length = 250)
	private java.lang.String userName; //userName
	@NotNull @Max(32767)
	
	@Column(name = "gender", unique = false, nullable = false, insertable = true, updatable = true, length = 5)
	private Short gender; //gender
	@Length(max=255)
	
	@Column(name = "password", unique = false, nullable = true, insertable = true, updatable = true, length = 45)
	private java.lang.String password; //password
	@Length(max=45)
	
	@Column(name = "mobile_phone", unique = false, nullable = true, insertable = true, updatable = true, length = 45)
	private java.lang.String mobilePhone; //mobilePhone
	@Length(max=45)
	
	@Column(name = "home_phone", unique = false, nullable = true, insertable = true, updatable = true, length = 45)
	private java.lang.String homePhone; //homePhone
	@Length(max=45)
	
	@Column(name = "work_phone", unique = false, nullable = true, insertable = true, updatable = true, length = 45)
	private java.lang.String workPhone; //workPhone
	
	
	@Column(name = "last_login_date", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	private java.sql.Timestamp lastLoginDate; //lastLoginDate
	
	
	//columns END



	
	
	
	public java.lang.String getLoginName() {
		return this.loginName;
	}
	
	public void setLoginName(java.lang.String value) {
		this.loginName = value;
	}

	public java.lang.String getUserName() {
		return this.userName;
	}
	
	public void setUserName(java.lang.String value) {
		this.userName = value;
	}

	public Short getGender() {
		return this.gender;
	}
	
	public void setGender(Short value) {
		this.gender = value;
	}

	public java.lang.String getPassword() {
		return this.password;
	}
	
	public void setPassword(java.lang.String value) {
		this.password = value;
	}

	public java.lang.String getMobilePhone() {
		return this.mobilePhone;
	}
	
	public void setMobilePhone(java.lang.String value) {
		this.mobilePhone = value;
	}

	public java.lang.String getHomePhone() {
		return this.homePhone;
	}
	
	public void setHomePhone(java.lang.String value) {
		this.homePhone = value;
	}

	public java.lang.String getWorkPhone() {
		return this.workPhone;
	}
	
	public void setWorkPhone(java.lang.String value) {
		this.workPhone = value;
	}

	public java.sql.Timestamp getLastLoginDate() {
		return this.lastLoginDate;
	}
	
	public void setLastLoginDate(java.sql.Timestamp value) {
		this.lastLoginDate = value;
	}


	@ManyToMany
	@JoinTable(name = "acct_user_role", joinColumns = { @javax.persistence.JoinColumn(name = "user_id") }, inverseJoinColumns = { @javax.persistence.JoinColumn(name = "role_id") })
	@Fetch(FetchMode.SUBSELECT)
	@OrderBy("id")
	@JsonIgnore
	private List<AcctRole> roleList = Lists.newArrayList();
	public List<AcctRole> getRoleList() {
		return this.roleList;
	}

	public void setRoleList(List<AcctRole> roleList) {
		this.roleList = roleList;
	}
	
	@Transient
	public List<String> getRoleNames() {
		return ConvertUtils.convertElementPropertyToList(getRoleList(), "roleName");
	}

}

